package com.example.demo.controller;

import com.example.demo.common.entity.MsgInfo;
import com.example.demo.common.entity.SysUser;
import com.example.demo.entity.Person;
import com.example.demo.entity.websocket.User;
import com.example.demo.service.SystemService;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/system")
public class SystemController {
    @Resource
    private SystemService systemService;
    @Resource
    private FlowExecutor flowExecutor;
    @RequestMapping("/selectAll")
    public MsgInfo selectAll(){
        List<User> sysUsers = systemService.selectAll();
        //修改
        return MsgInfo.ok(sysUsers);
    }

    /**
     * liteflow流程编排demo
     * @return
     */
    @RequestMapping("/testLiteFlow")
    public MsgInfo testLiteFlow(){
        Person person =new Person();
        person.setId("123").setName("张三");
        LiteflowResponse response = flowExecutor.execute2Resp("chain1", person, Person.class);
        return MsgInfo.ok(null);
    }
}
